package com.atguigu.flink.chapter05.transform;

import com.atguigu.flink.function.WaterSensorMapFunction;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 * @Author lzc
 * @Date 2023/6/19 08:52
 */
public class ReduceDemo_2 {
    public static void main(String[] args) {
        Configuration conf = new Configuration();
        conf.setInteger("rest.port", 2000);
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(conf);
        env.setParallelism(1);
        // 不同 sensor 的水位和
        env
            .readTextFile("input/sensor.txt")
            .map(new WaterSensorMapFunction())
            .keyBy(ws -> "a")
            .sum("vc")
            .print();
        
        
        
        try {
            env.execute();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
